package com.blank.black.entity.bo.example;

import com.blank.black.enums.LogicEnum;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

public class ExampleJoin {
    private String mode;
    private String tableName;
    private String alias;
    private List<ExampleJoinRelation> relationList;

    public  Boolean isFull(){
        if (Objects.isNull(this.getTableName()) || this.getTableName().length()<=0){
            return false;
        }
        if (Objects.isNull(this.getAlias()) || this.getAlias().length()<=0){
            return false;
        }

        return true;
    }

    public ExampleJoin addRelation(String alias1,
                                   String property1,
                                   String alias2,
                                   String property2) {
        return this.addRelation(ExampleJoinRelation.defaultLogic, alias1, property1, alias2, property2);
    }

    public ExampleJoin addRelation(LogicEnum logic,
                                   String alias1,
                                   String property1,
                                   String alias2,
                                   String property2) {
        ExampleJoinRelation exampleJoinRelation = new ExampleJoinRelation();
        exampleJoinRelation.setLogic(logic.getName());
        exampleJoinRelation.setAlias1(alias1);
        exampleJoinRelation.setAlias2(alias2);
        exampleJoinRelation.setProperty1(property1);
        exampleJoinRelation.setProperty2(property2);
        if (null == relationList) {
            relationList = new ArrayList<>();
        }
        relationList.add(exampleJoinRelation);
        return this;
    }

    public String getMode() {
        return mode;
    }

    public void setMode(String mode) {
        this.mode = mode;
    }

    public String getTableName() {
        return tableName;
    }

    public void setTableName(String tableName) {
        this.tableName = tableName;
    }

    public String getAlias() {
        return alias;
    }

    public void setAlias(String alias) {
        this.alias = alias;
    }

    public List<ExampleJoinRelation> getRelationList() {
        return relationList;
    }

    public void setRelationList(List<ExampleJoinRelation> relationList) {
        this.relationList = relationList;
    }
}
